import styles from './index.less';
import { useDispatch, useSelector } from 'react-redux';
import { increment, decrement } from '@/store/home';
import { RootState } from '@/store';
import { Button } from 'react-vant';
import { history } from 'umi';

export const Index = () => {
  const dispatch = useDispatch();
  const { count } = useSelector((state: RootState) => state.home);
  return (
    <div className={styles.page}>
      <div>当前设备：mobile-home</div>
      <div>当前计数（持久化缓存）：{count}</div>
      <div>
        <Button type="primary" onClick={() => dispatch(increment())}>
          +
        </Button>
        <Button
          className={styles.btn}
          type="primary"
          onClick={() => dispatch(decrement())}
        >
          -
        </Button>
      </div>
      <Button type="primary" onClick={() => history.push('/detail?id=3')}>
        跳转详情页-参数id=3
      </Button>
    </div>
  );
};
export default Index;
